#ifndef CONVERTER_H
#define CONVERTER_H

#include <QObject>
#include <QHostAddress>

class QTcpSocket;

class Converter : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QVariant state READ state WRITE setState NOTIFY stateChanged)
public:
    explicit Converter(const QHostAddress &host, quint16 port,
                       QObject *parent = 0);

    QVariant state() const;
    void setState(const QVariant &newState);
    
signals:
    void stateChanged(const QVariant &newState);
    
private slots:
    void connected();
    void readyRead();

private:
    QTcpSocket *m_socket;
    QString m_state;
    QString m_newState;
    QHostAddress m_host;
    quint16 m_port;

    enum STATUS { IDLE, SET_STATE, GET_STATE };
    STATUS m_status;
};

#endif // CONVERTER_H
